<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>超时理赔列表管理</title>
<jsp:include page="../../import.jsp" flush="true" />
	<style type="text/css">
        .searchArea .fieldBox .label{width: 70px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}

        .sq-button.sq-button-round.disabled{
            color: rgba(0,0,0,.30);
            background: #eaeaea;
            border: 1px solid #d8d8d8;
            cursor: not-allowed;
        }
    </style>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div id="pageInTab" class="pageInTab">
<div tabid="tabA" title="超时理赔列表" lselected="true">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">经销商</div>
                    <div class="field">
                        <input name="contNo" id="contNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">客户经理</div>
                    <div class="field">
                        <input name="cstMgrNm" id="cstMgrNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">实赔金额</div>
                    <div class="field">
                        <input ligerui="width: 82" name="payAmtMin" id="payAmtMin" type="text" class="ui-textbox" value="">
                        -
                        <input ligerui="width: 82" name="payAmtMax" id="payAmtMax" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="fieldBox">
                    <div class="label">支付表号</div>
                    <div class="field">
                        <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_33" id="cstMgrOrgCdId" >
	                <div class="label">所属公司</div>
	                <div class="field">
	                    <input name="cstMgrOrgCd" id="cstMgrOrgCd" type="text" class="ui-textbox" value="">
	                </div>
	            </div>
	            
                <div class="fieldBox">
                    <div class="label">实赔时间</div>
                    <div class="field">
                        <input ligerui="width: 82" name="actPayTmBg" id="actPayTmBg" type="text" class="ui-datepicker" value="">
                        -
                        <input ligerui="width: 82" name="actPayTmEd" id="actPayTmEd" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="clearFix"></div>
                <div class="fieldBox">
                    <div class="label">承租人</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">理赔状态</div>
                    <div class="field">
                        <input name="claStsCd" id="claStsCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
                <%--<div class="fieldBox">
                    <div class="label">所属区域</div>
                    <div class="field">
                        <input name="cstMgrRgnCd" id="cstMgrRgnCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>--%>

            <div class="clearFix"></div>
                <div class="btnsBox">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <span id="addBtn" class="sq-button sq-button-round flowBtn">发起理赔</span>
                </div>
            </div>
    </form>
</div>

<div id="ligergrid1" class="sq-grid"></div> 
</div>
<div tabid="tabB" title="流程跟踪" id="tabBId">
	<iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
</div>
</div>
</div>


<div id="chooseFlowDIV" style="display:none">
    <div id="ligergrid_flowStart" class="sq-grid"></div>
</div>
<div id="ywchange_result" style="display:none">
	<form id="ywchange_result_form">
	</form>
</div>
<script type="text/javascript">
var grid = null,callback=null;
var pageInApp={};
var currentOrgCd = '${currentOrgCd}';
$(function () {
	initTab();
	initOrgTree();	
    grid = $("#ligergrid1").ligerGrid({
           url: '<%=path%>/capital/capclaiminfo/initList.do',
           method: 'get',
           columns: [
               {display: '承租人', name: 'cstNm', minWidth: 100, align: 'left', enabledSort: false},
               {display: '支付表号', name: 'paySchNo', width: 150, align: 'left', enabledSort: false},
               {display: '放款金额', name: 'payAmt', width: 100, align: 'right', enabledSort: false,
                   render:function(rowdata,index,value){
                       return '&yen;'+FormatMoney(rowdata.payAmt/100);
                   }
               },
               {display: '实际放款时间', name: 'actPayTm', width: 140, align: 'center', enabledSort: false,render:renderDate},
               {display: '实际放款金额', name: 'actPayAmt', width: 100, align: 'right', enabledSort: false,
                   render:function(rowdata,index,value){
                       if(rowdata.actPayAmt){
                           return '&yen;'+FormatMoney(rowdata.actPayAmt/100);
                       }
                   }
               },
               {display: '总耗时', name: 'takeMsStr', width: 120, align: 'center', enabledSort: false},
               {display: '客户经理', name: 'cstMgrNm', width: 80, align: 'center', enabledSort: false},
               {display: '所属事业部', name: 'buOrgCdNm', width: 100, align: 'center', enabledSort: false},
               {display: '省公司', name: 'prOrgCdNm', width: 100, align: 'center', enabledSort: false},
               {display: '分公司', name: 'cyOrgCdNm', width: 100, align: 'center', enabledSort: false},
               /*{display: '所属区域', name: 'cstMgrRgnCdNm', width: 100, align: 'center', enabledSort: false},*/
               {display: '经销商', name: 'splNm', width: 100, align: 'center', enabledSort: false},
               {display: '协议状态', name: 'contStsCdNm', width: 80, align: 'center', enabledSort: false},
               {display: '理赔状态', name: 'claStsCdNm', width: 100, align: 'center', enabledSort: false},
               {display: '应赔金额', name: 'claimAmt', width: 100, align: 'right', enabledSort: false,
                   render:function(rowdata,index,value){
                       return '&yen;'+FormatMoney(rowdata.claimAmt/100);
                   }
               },
               {display: '实赔金额', name: 'payClaimAmt', width: 100, align: 'right', enabledSort: false,
                   render:function(rowdata,index,value){
                       return '&yen;'+FormatMoney(rowdata.payClaimAmt/100);
                   }
               },
               {display: '实赔时间', name: 'claimTm', width: 140, align: 'center', enabledSort: false,render:renderDate},
               {display: '理赔单', name: 'prInsNo', minWidth: 140, align: 'center', enabledSort: false,
                   render: function (rowdata, rowindex, value, column) {
                   	var h = '';
           			if(value&&value!="null"){            				
                        h+='<a href="javascript:commShowFlow(';
            		    h+="'"+rowdata.prInsId+"',";
            		    h+="'"+rowdata.audStsCd+"',";
            		    h+="'"+rowdata.id+"'";
            		    h+=')">'+value+'</a>'
           			}
                       return h;
                   },
               },      
           ],
           pageSize: 10,
           root: 'rows',
           record: 'total',
           hideLoadButton: true,
           width: '100%',
           height: '100%',
           heightDiff: -2,
           checkbox: true,
           rownumbers: true,
           allowUnSelectRow: true,
           alternatingRow: true,
           isSingleCheck:true,
           onSelectRow:function(rowdata, rowid, rowobj){            	
           	if(rowdata.claStsCd!="4"){
                   $(".flowBtn").addClass("disabled").attr("flowKey","");
                   return;
               }else{
               	$(".flowBtn").removeClass("disabled").attr("flowKey","");
               }
           },
           onUnSelectRow:function(rowdata, rowid, rowobj){
               $(".flowBtn").removeClass("disabled").attr("flowKey","");
           }
       });
       grid.setHeight(100);

       $("#searchBar").ligerForm();
       //项目类型
       $("#claStsCd").ligerComboBox({
           valueField: 'key',
           textField: 'value'
       });
       liger.get("claStsCd").setData(${claStsCdList});
       //所属区域
       /*$("#cstMgrRgnCd").ligerComboBox({
           valueField: 'key',
           textField: 'value'
       });
       liger.get("cstMgrRgnCd").setData(${regionList});*/


       $("#pageloading").hide();

       /* 查询 */
       $("#searchBtn").click(function (event) {
           var form = liger.get("searchBar");
           var data = form.getData();
           for (name in data) {
               grid.setParm(name, data[name]);
           }
           grid.reload();
       });

       /* 清空 */
       $("#clearBtn").click(function (event) {
           clearLigerForm("searchBar");
       });
       
       $("#addBtn").click(function (event) {
           if($("#addBtn").attr("class").indexOf("disabled")>0){
               return;
           }
           addFlowStart();
       });

       callback = function () {
           grid.reload();
       };
});	    
function initOrgTree(){
   	var params = {};
   	params.userId = '${currentUserId}';
   	params.cstMgrOrgCd = '${currOrg}';
   	 searchOrgTree = $("#cstMgrOrgCd").ligerComboBox({
  		width: 480,
        selectBoxWidth: 480,
        selectBoxHeight: 150,
        //限制只能选叶节点，父节点不能点击
        treeLeafOnly: false,
        valueField: 'orgCd',
        textField: 'orgDispNm',
        showTreePath: true,
        tree: {
            ajaxType: 'get',
            idFieldName:'orgCd',
            textFieldName: 'orgDispNm',
            checkbox: false,
            parentIcon: "none",
            childIcon: "none",
            needCancel : false
        }
     });
   	 $.ajax({
   		type: 'get',
   		dataType:'json',
   		data: params,
   		url: '<%=path%>/project/prjbscinfo/searchBuOrgTree.do',
   		success:function(msg){
   			if(msg.success == 1){
   				searchOrgTree.treeManager.setData(msg.data);
   				searchOrgTree.clear();
   				searchOrgTree.setValue('${currOrg}');
   			}else{
   				 $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
   			}
   		}
    });

}    
	    
var loadedTabs = [];
//初始化Tab页签
function initTab(){
	pageInTab = $("#pageInTab").ligerTab({
		height: 'auto',
		contextmenu: false,
		minIframeHeight: GET_minIframeHeight(),
		onBeforeSelectTabItem: function(tabid) {
			var selectedRows = grid.getSelectedRows();
			//var projectId = $("#projectId").val();
			if(tabid!="tabA"){
				if (selectedRows.length != 1) {
		             $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
		             return false;
		         }
			}
		},
		onAfterSelectTabItem: function(tabid) {
			var selectedRows = grid.getSelectedRows();
			var projectId = $("#projectId").val();
			if(tabid!="tabA"){
				if (selectedRows.length != 1) {
		             $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
		             return false;
		         }else{
					if (loadedTabs.indexOf(selectedRows[0].id)<0) {
						loadedTabs = [];
						loadedTabs.push(selectedRows[0].id);
						switch (tabid){
							case "tabB":							
								pageInTab.setTabItemSrc(tabid, "<%=path%>/capital/capclaiminfo/toCapClaimFlowPage.do?selecId="+selectedRows[0].id);
								break;
						}
					}
					SetIframe_height();
				}
			}
		}
	});
	$.extend(true, pageInApp, {
       pageInTab: pageInTab
    });
}
//显示流程
function commShowFlow(_pInstId, _audStsCd, _businessKey){
   	if(StringUtils.isEmpty(_pInstId)){
   		UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
   		return;
   	}
   	var _formUrl = "/capital/capclaiminfo/toAdditionalInfoPage.do?isDetail=1@@ctrlKey=0@@processInstanceId="+_pInstId+"@@claimId=";
   	var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
   	Add_navTab('tab_cst_invoice_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);
}
//格式化时间
function renderDate(rowdata, index, value){
	var dateStr = "";
	if(null != value){
		var date = new Date(value);
		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
	}
	return dateStr;
}
function addFlowStart(){
	var selectedRows = grid.getSelectedRows();
    if (selectedRows.length != 1) {
        $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
        return;
    }
    var prjStsCd = selectedRows[0].claStsCd;//理赔状态
    if(prjStsCd=="1"){
        $.ligerDialog.SQalert({content: "理赔审核中,不允许多次发起流程.", SQ_type: "warning"});
        return;
    }else if(prjStsCd=="2"){
        $.ligerDialog.SQalert({content: "理赔放款中,不允许再次发起流程.", SQ_type: "warning"});
        return;
    }else if(prjStsCd=="3"){
        $.ligerDialog.SQalert({content: "理赔已成功,不允许再次发起流程.", SQ_type: "warning"});
        return;
    }

      //发起流程确认 
    $.ligerDialog.confirm(FlowConstant.FLOW_ADD_START_CONFIRM, function (flag) {
		if(flag == false){
            wait_dialog.close();
	    	return;
        }
        var claimId = selectedRows[0].id;
        var wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting",onClose: function () {}});
        $.ajax({
	   		type: 'post',
	   		dataType:'json',
	   		url: '<%=path%>/project/audit/addFlowStart.do?id='+claimId,
	   		success:function(msg){
	   			 wait_dialog.close();
	   			 if(msg.success == 1){//成功发起流程
	  					 UIUtils.alertSuccessHold1(msg.info);
	   				 grid.reload();
	   			 }else if(msg.success == 0){//错误
	  					 UIUtils.alertErrorHold1(msg.info);
	   			 }
	   		}
   		});
    });
}	
</script>

</body>
</html>